/*
 * @Author jiangzhiwei
 * @Date 2023-07-22 19:19:18
 * @LastEditors jiangzhiwei
 * @LastEditTime 2023-07-25 15:10:25
 * @FilePath \test-cron\src\components\yc-cron\components\panes\year-pane\index.js
 * @Description 年面板
 */
import { defineComponent, markRaw } from 'vue-demi'
import { DEFAULT_YEAR_DESCRIPTIONS, parseConfig } from '../../../utils/config'
import { h } from '../../../utils/domutil'
import paneMixin from '../mixins/panemixin'
import CommonPerOption from '../../options/common-per-option'
import CommonDurationOption from '../../options/common-duration-option'
import CommonStartOption from '../../options/common-start-option'
import CommonDesignateOption from '../../options/common-designate-option'
import CommonNotDesignateOption from '../../options/common-not-designate-option'

const NAME = 'yc-cron-year-pane'

export default defineComponent({
  name: NAME,
  mixins: [paneMixin],
  props: {
    /** 年配置面板开始年份 */
    startNum: {
      type: Number,
      default: 2000
    },
    /** 年配置面板可选年份总数 */
    total: {
      type: Number,
      default: 70
    }
  },
  data () {
    const total = this.total
    const startNum = this.startNum
    return {
      /** 各个选项的配置信息 */
      options: [
        { label: markRaw(CommonPerOption) },
        { label: markRaw(CommonDurationOption), props: { total, startNum } },
        { label: markRaw(CommonStartOption), props: { total, startNum } },
        { label: markRaw(CommonDesignateOption), props: { total, startNum } },
        { label: markRaw(CommonNotDesignateOption) }
      ]
    }
  },
  computed: {
    descriptions () {
      return parseConfig(DEFAULT_YEAR_DESCRIPTIONS)
    }
  },
  render () {
    return h('ul', this.generateOptionNodes())
  }
})
